﻿using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;

namespace LetiLib.Connection
{
    /// <summary>
    /// Tag use to send/receive
    ///   
    /// Send data format:
    ///*    - <server tag> <command> <length - optional> <data>
    ///*    <server tag>: 0x01
    ///*    <control command>:
    ///*        - UPDATE: 0x10 + <length> <data>
    ///*        - SET_BRIGHT: 0x11 + <4 byte data>
    ///*        - GET_BRIGHT: 0x12
    ///*        - CHECK_LED: 0x13
    ///*        - SET_PASSWORD: 0x14 : <length> <data>
    ///*        - GET_PASSWORD: 0x15
    ///*        
    ///*    <communicate command>
    ///*        - PING: 0x20
    ///*        - ACK: 0x20
    ///*        - NACK: 0x21
    ///*        - ERROR_1: 0x22
    ///*        - ERROR_2: 0x23
    ///*        ....
    ///
    public struct CONST
    {
        public const int FONT_PACKAGE_LENGTH = 1024;
        public const int DATA_PACKAGE_LENGTH = 1024;
        public const int FIRMWARE_PACKAGE_LENGTH = 1000;
    }

    public enum COMMAND
{
   		SERVER_TAG = 0x00,
        DEVICE_TAG,
        PING ,

		// Font data update commands
        CMD_SERVER_FONT_UPDATE_REQ = 0x20,
        FONT_INFO_HEADER,
        FONT_PACKAGE_HEADER,

        // Bitmap data update commands
        CMD_SERVER_DATA_UPDATE_REQ = 0x30,
        DATA_INFO_HEADER,
        DATA_PACKAGE_HEADER,
        
        // FIRMWARE update commands
        CMD_SERVER_FIRMWARE_UPDATE_REQ = 0x40,
        FIRMWARE_INFO_HEADER,
        FIRMWARE_PACKAGE_HEADER,

        // Image binary commands
    	CMD_INSERT_IMAGE = 0x50,
        CMD_UPDATE_IMAGE,
        CMD_DELETE_IMAGE,
        CMD_DELETE_ALL_IMAGE,
        CMD_GET_LIST_IMAGE_INDEX,
        
        // Page control commands
        CMD_CREATE_PAGE = 0x60,
        CMD_UPDATE_PAGE,
        CMD_DELETE_PAGE,
        CMD_GET_PAGE_INFO,
        CMD_SET_ACTIVE_PAGE,
        CMD_GET_ACTIVE_PAGE,
        
        // Popup control commands
        CMD_INSERT_POPUP = 0x70,
        CMD_UPDATE_POPUP,
        CMD_DELETE_POPUP,

        // Playlist control commands
        CMD_SERVER_PLAYLIST_UPDATE_REQ = 0x80,
        PLAYLIST_INFO_HEADER,
        CMD_INSERT_IMAGE_TO_PLAYLIST,
        CMD_UPDATE_IMAGE_TO_PLAYLIST,
        CMD_DELETE_IMAGE_FROM_PLAYLIST,

        // Control commands server sent to device
        GET_VERSION = 0xA0,
        GET_PASSWORD,
        SET_PASSWORD,
        GET_BRIGHTNESS,
        SET_BRIGHTNESS,
        // CMD_UPDATE_BUS_DATA,// Temporary disable, just hardcode for testing
        CMD_CHECK_LED,
        CMD_CLEAR_LED,
        CMD_SCAN_LED,
        CMD_CAPTURE_SCREEN,
        CMD_GET_STATUS,
        CMD_SET_PREDEFINE,
        CMD_REBOOT,
        CMD_SHUTDOWN,

        // Device commands sent back to server
        CMD_SEND_IMEI = 0xD0,
        // Screen data sent from device
        LED_INFO_HEADER,
        LED_SCREEN_DATA,
        LED_STATUS_DATA,

        // Warning data
        WARNING_TOO_HOT,
        WARNING_DAMAGED,
        WARNING_OUT_OF_POWER,
        WARNING_OPENNED
    }

    public enum DEVICE_RESPONSE
    {
        SUCCESS,
        ERROR,
        ERROR_ID_DUPLICATE,
        ERROR_ID_NOT_FOUND,
        ERROR_STORAGE_NOT_AVAIBLE,
        ERROR_DATA_IMAGE_FORMAT,
        ERROR_PACKAGE_ID,
        ERROR_PACKAGE_CHECKSUM
    }
}
